<template>
  <div class="container">
    <video class="video" :src="url" autoplay="true" controls></video>
    <div class="info">
      <div class="singer">
        <img class="singer-img" :src="singerinfo.artist.cover" />
        <span class="singer-name">{{ singerinfo.artist.name }}</span>
      </div>
      <div class="mv">
        <div class="mv-title">
          <span class="icon">MV</span>
          <div class="title">{{ info.name }}</div>
        </div>
        <div class="mv-info">
          <span class="mv-playcount">{{ info.playCount }}次播放</span>
          <span class="mv-time">{{ info.publishTime }}</span>
        </div>
        <div class="mv-detail">{{ info.desc }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      id: "",
      singerid: "",
      url: "",
      singerinfo: [],
      info: [],
    };
  },
  created() {},
  methods: {
    getUrl() {
      (this.id = this.$route.params.id),
        axios
          .get("api/mv/url?id=" + this.id + "&r=1080")
          .then((res) => {
            console.log(res.data.data.url);
            this.url = res.data.data.url;
          })
          .catch((err) => {
            console.error(err);
          });
    },
    getArtistData() {
      (this.singerid = this.$route.params.singerid),
        axios
          .get("api/artist/detail?id=" + this.singerid)
          .then((res) => {
            console.log(res.data.data);
            this.singerinfo = res.data.data;
          })
          .catch((err) => {
            console.error(err);
          });
    },
    getMvData() {
      (this.id = this.$route.params.id),
        axios
          .get("api/mv/detail?mvid=" + this.id)
          .then((res) => {
            console.log(res.data.data);
            this.info = res.data.data;
          })
          .catch((err) => {
            console.error(err);
          });
    },
  },
  mounted() {
    this.getUrl();
    this.getArtistData();
    this.getMvData();
  },
  filters: {
    numFilter(value, num) {
      return parseFloat(value).toFixed(num);
    },
  },
};
</script>

<style scoped>
.container{
  text-align: left;
}
.video {
  width: 100%;
}
.info {
  padding: 5px 15px;
}
.singer {
  height: 30px;
}
.singer-img {
  width: 30px;
  height: 30px;
  border-radius: 15px;
  border: 2px #eee solid;
}
.singer-name {
  margin-left: 10px;
  display: inline-block;
  position: relative;
  top: -10px;
  font-size: 15px;
  font-weight: 600;
}
.mv-title {
  margin-top: 10px;
  height: 15px;
}
.mv-title > .icon {
  border: 1px #eb4d44 solid;
  font-size: 10px;
  color: #eb4d44;
  padding: 0 2px;
}
.mv-title > .title {
  display: inline-block;
  margin-left: 10px;
  font-size: 15px;
}
.mv-info {
  margin-top: 10px;
  font-size: 10px;
  color: #838383;
}
.mv-info > .mv-time {
  margin-left: 10px;
}
.mv-detail {
  margin-top: 10px;
  font-size: 13px;
  line-height: 20px;
}
</style>
